Skip to content

use bazel 8 (bzlmod migration) #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Dec 16, 2024
Merged

use bazel 8 (bzlmod migration) #134

merged 33 commits into from
Dec 16, 2024

Conversation

tekumara
Copy link
Contributor

@tekumara tekumara commented Dec 14, 2024

Migrates to bzlmod which is required by Bazel 8 see https://bazel.build/external/migration

Go deps are now defined in go.mod

Resolves #131

MODULE.bazel Outdated
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(
name = "protobuf",
version = "26.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously we were using 25.2 but that doesn't exist on bazel central

@tekumara
Copy link
Contributor Author

NB: This PR has lots of WIP commits - I recommend squash merging it.

"@com_github_jayaprabhakar_go_clone//:go-clone",
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@com_github_huandu_go_clone//:go-clone",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tekumara One reason I had to fork the cloning library was it was missing a feature to override pointer references.
huandu/go-clone#23

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still using your fork - see the replace statement in go.mod

I had to do it like this to make go.mod work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming bazel honours this but admittedly I haven't tested this - is there a way to test this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks.

@jayaprabhakar
Copy link
Collaborator

Thanks for the PR. I only have one issue. Is there a reason to switch one of the dependency?

@jp-fizzbee jp-fizzbee merged commit fb19e8a into fizzbee-io:main Dec 16, 2024
@jp-fizzbee
Copy link
Collaborator

I ran it, I see this error.

Starting local Bazel server and connecting to it...
WARNING: For repository 'protobuf', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: Couldn't auto load rules or symbols, because no dependency on module/repository 'rules_android' found. This will result in a failure if there's a reference to those rules or symbols.
INFO: Analyzed 2 targets (135 packages loaded, 5344 targets configured).
INFO: From Linking external/protobuf+/src/google/protobuf/io/libio_win32.a [for tool]:
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/protobuf+/src/google/protobuf/io/libio_win32.a the table of contents is empty (no object file members in the library define global symbols)
ERROR: /private/var/tmp/_bazel_jp/44f378705132ae1485a21c4be97e06a5/external/protobuf+/src/google/protobuf/io/BUILD.bazel:99:11: Compiling src/google/protobuf/io/printer.cc [for tool] failed: (Exit 1): cc_wrapper.sh failed: error executing CppCompile command (from target @@protobuf+//src/google/protobuf/io:printer) external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object ... (remaining 50 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/protobuf+/src/google/protobuf/io/printer.cc:12:
bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/protobuf+/src/google/protobuf/io/_virtual_includes/printer/google/protobuf/io/printer.h:918:19: error: 'get<std::function<bool ()>, std::string, std::function<bool ()>>' is unavailable: introduced in macOS 10.13
    value = absl::get<Callback>(that.value);
                  ^
bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/protobuf+/src/google/protobuf/io/_virtual_includes/printer/google/protobuf/io/printer.h:863:11: note: in instantiation of function template specialization 'google::protobuf::io::Printer::ValueImpl<false>::operator=<true>' requested here
    *this = that;
          ^
bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/protobuf+/src/google/protobuf/io/_virtual_includes/printer/google/protobuf/io/printer.h:1150:12: note: in instantiation of function template specialization 'google::protobuf::io::Printer::ValueImpl<false>::ValueImpl<true>' requested here
    return ValueView(it->second);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/variant:1577:22: note: 'get<std::function<bool ()>, std::string, std::function<bool ()>>' has been explicitly marked unavailable here
constexpr const _Tp& get(const variant<_Types...>& __v) {
                     ^
1 error generated.
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 20.992s, Critical Path: 2.82s
INFO: 704 processes: 458 internal, 246 darwin-sandbox.
ERROR: Build did NOT complete successfully
⏺ jp@ /Users/jp/src1/fizzbee (main) # 


@jayaprabhakar
Copy link
Collaborator

It looks like this is an issue with Mac.
protocolbuffers/protobuf#16944

The current workaround should be to add

build --host_cxxopt=-std=c++14 --cxxopt=-std=c++14

To .bazelrc

I'm not sure if this works in Linux.

@tekumara
Copy link
Contributor Author

Interesting I didn't hit that on my Mac.

I notice we are using an old version of protobuf.

I've tried the PR without that .bazelrc on Ubuntu arm64 and it built fine.

@tekumara tekumara deleted the bazel8 branch December 16, 2024 23:53
@jp-fizzbee
Copy link
Collaborator

For now, I added build --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 to my local .bazelrc to make it work. I am not sure if it is an issue on mine or others too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot build using bazel 8
3 participants